#pragma once

#include"nanoSignalSlot/nano_signal_slot.hpp"
#include "realize2.h"
#ifndef useSignalSlotWithEvenLoop_h__
#define useSignalSlotWithEvenLoop_h__

class person {

public:
	void eatASync() {
		loop.enqueue(std::bind(&person::eat, this));
	}
	void sleepASync() {
		loop.enqueue(std::bind(&person::sleep, this));
	}
	void goOutASync() {
		loop.enqueue(std::bind(&person::goOut, this));
	}

	void goWhereAsync(const std::string& value) {
		loop.enqueue(std::bind(&person::goSomeWhere, this, value));
	}

	void eat() {
		std::cout << "thread id " << std::this_thread::get_id() << ",eat \n";
	}
	void sleep() {
		std::cout << "thread id " << std::this_thread::get_id() << ",sleep \n";

	}
	void goOut() {
		std::cout << "thread id " << std::this_thread::get_id() << ",go out \n";

	}

	void goSomeWhere(const std::string& place) {
		std::cout << "thread id " << std::this_thread::get_id() << ",go to " << place << "\n";
	}
private:

	realize2 loop;
};



int testThis() {

	person li;
	Nano::Signal<void()> signal1;
	signal1.connect<&person::eatASync>(li);
	signal1.connect<&person::sleepASync>(li);
	signal1.connect<&person::goOutASync>(li);
	signal1.connect<&person::goOut>(li);
	signal1.fire();
	Nano::Signal<void(const std::string&)> signal2;
	signal2.connect<&person::goWhereAsync>(li);
	signal2.connect<&person::goSomeWhere>(li);
	signal2.fire("henan");
	return 1;
}


#endif // useSignalSlotWithEvenLoop_h__